package com.clementheliou.cheliou.dal.model.base;

import javax.persistence.MappedSuperclass;

import org.apache.commons.lang3.builder.EqualsBuilder;

/**
 * Base entity that must be extended by all module's entities. It groups common properties and
 * methods.
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @see {@link MappedSuperclass}.
 * @since 1.0
 */
@MappedSuperclass
public abstract class BaseEntity {

	/**
	 * Identifier of the entity. It should be linked to a DB sequence by its getter.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	protected Integer id;

	/**
	 * Protected default constructor to be sure that only subclasses can use it.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	protected BaseEntity() {
	}

	/**
	 * <i>{@inheritDoc}</i>
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @see {@link EqualsBuilder#reflectionEquals(Object, Object)}.
	 * @since 1.0
	 */
	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}

	/*
	 * Getters & setters.
	 */

	public void setId(Integer id) {
		this.id = id;
	}

}
